package com.mc2.docapp.disabilityassessmenttool.SpinalAffection;

public class Class_spinal_affection {
    private C_traumetic_affection c_traumetic_affection =  new C_traumetic_affection();
    private C_Scoliosis_Component c_scoliosis_component = new C_Scoliosis_Component();
    private C_kyphosis c_kyphosis = new C_kyphosis();
    private C_spin_affn_misc_med_conditions c_spin_affn_misc_med_conditions = new C_spin_affn_misc_med_conditions();
    private C_neurological_deficit c_neurological_deficit = new C_neurological_deficit();
    private double totalSpinalDisability;


    public void calc(Class_spinal_affection dt) {
        double a = dt.getC_traumetic_affection().getTraumeticAfffection();
        double b = dt.getC_scoliosis_component().getTotalScoliosis();
        double c = dt.getC_kyphosis().getInnerCalculations();
        double d = dt.getC_spin_affn_misc_med_conditions().getMedicalConditions();
        double e = dt.getC_neurological_deficit().getTotalNeuroDeficit();

        double step1;
        double step2;
        double step3;
        double step4;

        step1 = calByFormula(a,b);
        step2 = calByFormula(step1,c);
        step3 = calByFormula(step2,d);
        step4 = calByFormula(step3, e);

        dt.setTotalSpinalDisability(step4);

    }

    public double getTotalSpinalDisability() {
        return totalSpinalDisability;
    }

    public void setTotalSpinalDisability(double totalSpinalDisability) {
        this.totalSpinalDisability = totalSpinalDisability;
    }

    private double calByFormula(double a, double b) {
        if(a<b){
            a = a + b;
            b = a - b;
            a = a - b;
        }
        if(a > 90) {
            return a;
        }
        double c = a + (((90 - a) * b) / 90.0);
        return c;
    }

    public Class_spinal_affection(C_traumetic_affection c_traumetic_affection, C_Scoliosis_Component c_scoliosis_component, C_kyphosis c_kyphosis, C_spin_affn_misc_med_conditions c_spin_affn_misc_med_conditions, C_neurological_deficit c_neurological_deficit) {
        this.c_traumetic_affection = c_traumetic_affection;
        this.c_scoliosis_component = c_scoliosis_component;
        this.c_kyphosis = c_kyphosis;
        this.c_spin_affn_misc_med_conditions = c_spin_affn_misc_med_conditions;
        this.c_neurological_deficit = c_neurological_deficit;
    }

    public C_traumetic_affection getC_traumetic_affection() {
        return c_traumetic_affection;
    }

    public void setC_traumetic_affection(C_traumetic_affection c_traumetic_affection) {
        this.c_traumetic_affection = c_traumetic_affection;
    }

    public C_Scoliosis_Component getC_scoliosis_component() {
        return c_scoliosis_component;
    }

    public void setC_scoliosis_component(C_Scoliosis_Component c_scoliosis_component) {
        this.c_scoliosis_component = c_scoliosis_component;
    }

    public C_kyphosis getC_kyphosis() {
        return c_kyphosis;
    }

    public void setC_kyphosis(C_kyphosis c_kyphosis) {
        this.c_kyphosis = c_kyphosis;
    }

    public C_spin_affn_misc_med_conditions getC_spin_affn_misc_med_conditions() {
        return c_spin_affn_misc_med_conditions;
    }

    public void setC_spin_affn_misc_med_conditions(C_spin_affn_misc_med_conditions c_spin_affn_misc_med_conditions) {
        this.c_spin_affn_misc_med_conditions = c_spin_affn_misc_med_conditions;
    }

    public C_neurological_deficit getC_neurological_deficit() {
        return c_neurological_deficit;
    }

    public void setC_neurological_deficit(C_neurological_deficit c_neurological_deficit) {
        this.c_neurological_deficit = c_neurological_deficit;
    }

}
